<?php
class Photo extends AppModel {
 
    var $name = 'Photo'; 
    var $order = 'Photo.id ASC';
    
    public function beforeDelete(){
    	try {
    		$photo = $this->findById($this->id);
	    	$filename = $photo['Photo']['filename'];
	    	if(file_exists("img/Photos/big/".$filename))
	    		unlink("img/Photos/big/".$filename);
	        if(file_exists("img/Photos/small/".$filename))
	    		unlink("img/Photos/small/".$filename);
    	} catch (Exception $e){
    		echo $e->getMessage();
    	}
    	
    	return true;
    }
    
} 
?>